<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>08_员工列表练习</title>
</head>
<body>
<input type="text" id="i1" placeholder="请输入员工姓名">
<input type="text" id="i2" placeholder="请输入员工工资">
<input type="text" id="i3" placeholder="请输入员工岗位">
<button onclick="add()">添加员工</button>
<hr>
<table border="1px">
    <caption>员工表</caption>
    <tr>
        <th>姓名</th>
        <th>工资</th>
        <th>岗位</th>
    </tr>
</table>
<script>
    let arr = [];
    function add(){
        let name = document.getElementById('i1').value;
        let salary = document.getElementById('i2').value;
        let job = document.getElementById('i3').value;
        console.log(name,salary,job);
        let tableE = document.querySelector('table');
        let trE = document.createElement('tr');

        let td1E = document.createElement('td');
        td1E.innerHTML = name;
        let td2E = document.createElement('td');
        td2E.innerHTML = salary;
        let td3E = document.createElement('td');
        td3E.innerHTML = job;
        trE.append(td1E,td2E,td3E);
        tableE.append(trE);
        document.getElementById('i1').value = '';
        document.getElementById('i2').value = '';
        document.getElementById('i3').value = '';
        arr.push({
            name:name,
            salary:salary,
            job:job
        });
        console.log(arr);
    }
</script>
</body>
</html>